using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Mean.Net
{
    public partial class frmPercentFinder : Form
    {
        public frmPercentFinder()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            decimal percentage;
            string percentageStr;

            //Make sure there's some data in the text boxes.
         if(Convert.ToDecimal(txtCorrect.Text.Length) < 1)
         {
             txtCorrect.Text = "1";
         }

         if(Convert.ToDecimal(txtTotal.Text.Length) < 1)

         {
             txtTotal.Text = "1";
         }

            //x / y = w.ff
            //x out of y; w would be a whole number, ff is a fraction. 1 is 100%,
            //.99 is 99% and so on
            percentage = Convert.ToDecimal(Convert.ToDecimal(txtCorrect.Text) / Convert.ToDecimal(Convert.ToDecimal(txtTotal.Text)));
            //Turn the result in to a string so we can remove the decimal
            percentageStr = Convert.ToString(percentage);
            percentageStr.Replace(".","");
            //Display the percentage and clear the input fields
            txtPercent.Text = percentageStr + "%";
            txtCorrect.Clear();
            txtTotal.Clear();
        }

        private void label4_Click(object sender, EventArgs e)
        {

        }
    }
}